package com.web.hilover.controller;

import com.web.hilover.entity.Couple;
import com.web.hilover.entity.Quote;
import com.web.hilover.service.CoupleService;
import com.web.hilover.service.QuoteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.List;

@Controller
@Slf4j
public class IndexController {
    
    @Autowired
    private CoupleService coupleService;
    
    @Autowired
    private QuoteService quoteService;
    
    @GetMapping({"/", "/index"})
    public String index(Model model) {
        // 获取点赞数最多的情侣
        List<Couple> topCouples = coupleService.getTopCouples(6);
        log.info("Top couples: {}", topCouples);
        
        // 获取随机情侣
        List<Couple> randomCouples = coupleService.getRandomCouples(6);
        log.info("Random couples: {}", randomCouples);
        
        // 获取随机名言
        Quote randomQuote = quoteService.getRandomQuote();
        
        model.addAttribute("topCouples", topCouples);
        model.addAttribute("randomCouples", randomCouples);
        model.addAttribute("quote", randomQuote);
        
        return "index";
    }
} 